#include <my_header.h>

/* Usage: ./1_redirect_write filename */
int main(int argc, char *argv[]){                                  
    ARGS_CHECK(argc, 2);
    FILE *fp = fopen(argv[1], "w+");
    ERROR_CHECK(fp, NULL, "fopen");

    // fileno函数用于获取文件流当中的文件描述符
    int fd = fileno(fp);
    ssize_t ret =  write(fd, "hello", 5);
    ERROR_CHECK(ret, -1, "write");
    printf("\n");
    fclose(fp);
    return 0;
}


